﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dbPoll_Application.Models.AccountManagerModel>" %>
    
        <% Html.ValidationSummary(true); %>
        <%= Html.HiddenFor(model => model.SelectedRole)%>
	    <%= Html.HiddenFor(model => model.IsEditable)%>
	    <%= Html.HiddenFor(model => model.IsNew)%>
	    <% if (Model.IsEditable == false)
        { %>
        <%= Html.HiddenFor(model => model.UserName)%>
        <% } %>
    <table id="CreateTable" style="float:left">
	    <tr>
	    <td align="right"><label for="UserName"><span style="color: Red;">*</span>Username:</label></td>
	    <td><%= (Model.IsEditable == true) ? Html.TextBoxFor(model => model.UserName) : Html.TextBoxFor(model => model.UserName, new { @readonly = true })%></td>
	    <td><span id="UserNameMessage"><%= Html.ValidationMessageFor(model => model.UserName)%></span></td>
	    </tr>
	    <tr id="EmailRow">
	    <td align="right"><label for="Email"><span style="color: Red;">*</span>E-mail:</label></td>
	    <td><%= (Model.IsNew == true) ? Html.TextBoxFor(model => model.Email) : Html.TextBoxFor(model => model.Email, new { @readonly = true })%></td>
	    <td><span id="EmailMessage"><%= Html.ValidationMessageFor(model => model.Email)%></span></td>
	    </tr>
	    <% if (Model.SelectedRole == "Poll Administrator")
           { %>
	    <tr>
	    <td align="right"><label for="AccountExpiryDate">Expiry Date:</label></td>
	    <td><input name="AccountExpiryDate" id="AccountExpiryDate" type="text" class="datepicker" value="<%= Model.AccountExpiryDate.ToString("dd/MM/yyyy hh:mm tt") %>" readonly="readonly" /></td>
        </tr>
        <% } %>
	    <% if (Model.SelectedRole == "Poll User")
        {
            foreach (var item in Model.GenericEmails)
            {
                Html.RenderPartial("GenericEmailRow", item);
            }
        } %>
        <%
        if (Model.SelectedRole != "Poll User")
        {%>
	    <tr>
	    <td align="right"><label for="FirstName">First Name:</label></td>
	    <td><%= (Model.IsEditable == true || Model.SelectedRole == "Poll Administrator") ? Html.TextBoxFor(model => model.FirstName, new { @class = "textBox" }) : Html.TextBoxFor(model => model.FirstName, new { @readonly = true, @class = "textBox" })%></td>
	    <td><span><%= Html.ValidationMessageFor(model => model.FirstName)%></span></td>
	    </tr>
	    <tr>
	    <td align="right"><label for="LastName">Last Name:</label></td>
	    <td><%= (Model.IsEditable == true || Model.SelectedRole == "Poll Administrator") ? Html.TextBoxFor(model => model.LastName, new { @class = "textBox" }) : Html.TextBoxFor(model => model.LastName, new { @readonly = true, @class = "textBox" })%></td>
	    <td><span><%= Html.ValidationMessageFor(model => model.LastName)%></span></td>
	    </tr>
        <tr align="right">
        <td><label>Gender:</label></td>
        <td align="left"><label for="Male">Male:</label><%= (Model.IsEditable == true || Model.SelectedRole == "Poll Administrator") ?
                                    Html.RadioButtonFor(model => model.Gender, dbPoll_Application.Models.Gender.Male) :
                                    Html.RadioButtonFor(model => model.Gender, dbPoll_Application.Models.Gender.Male, new { @disabled = true })%>
        <label for="Female">Female:</label><%= (Model.IsEditable == true || Model.SelectedRole == "Poll Administrator") ?
                                    Html.RadioButtonFor(model => model.Gender, dbPoll_Application.Models.Gender.Female) :
                                    Html.RadioButtonFor(model => model.Gender, dbPoll_Application.Models.Gender.Female, new { @disabled = true })%></td>
        <td><%= Html.ValidationMessageFor(model => model.Gender)%></td>
        </tr>
	    <tr>
	    <td align="right"><label for="Organisation">Organisation:</label></td>
	    <td><%= (Model.IsEditable == true || Model.SelectedRole == "Poll Administrator") ? Html.TextBoxFor(model => model.Organisation) : Html.TextBoxFor(model => model.Organisation, new { @readonly = true })%></td>
	    <td><span><%= Html.ValidationMessageFor(model => model.Organisation)%></span></td>
	    </tr>
	    <tr>
	    <td align="right"><label for="Position">Position:</label></td>
	    <td><%= (Model.IsEditable == true || Model.SelectedRole == "Poll Administrator") ? Html.TextBoxFor(model => model.Position) : Html.TextBoxFor(model => model.Position, new { @readonly = true })%></td>
	    <td><span><%= Html.ValidationMessageFor(model => model.Position)%></span></td>
	    </tr>
	    <tr>
	    <td align="right"><label for="City">City:</label></td>
	    <td><%= (Model.IsEditable == true || Model.SelectedRole == "Poll Administrator") ? Html.TextBoxFor(model => model.City, new { @class = "textBox" }) : Html.TextBoxFor(model => model.City, new { @readonly = true, @class = "textBox" })%></td>
	    <td><span><%= Html.ValidationMessageFor(model => model.City)%></span></td>
	    </tr>
	    <tr>
	    <td align="right"><label for="Country">Country:</label></td>
	    <td><%= (Model.IsEditable == true || Model.SelectedRole == "Poll Administrator") ? Html.TextBoxFor(model => model.Country, new { @class = "textBox" }) : Html.TextBoxFor(model => model.Country, new { @readonly = true, @class = "textBox" })%></td>
	    <td><span><%= Html.ValidationMessageFor(model => model.Country)%></span></td>
	    </tr>
        <%
        } %>
        <% if (Model.SelectedRole == "Poll User")
           { %>
	    <tr>
	    <td align="right"><label for="IsGeneric">Generic:</label></td>
	    <td><%= (Model.IsEditable == true) ? Html.CheckBoxFor(model => model.IsGeneric) : Html.CheckBoxFor(model => model.IsGeneric, new { @disabled = true })%></td>
	    <td></td>
	    </tr>
	    <tr align="right">
	    <td><input type="button" value="Add Email" id="AddEmail" style="display:none" /></td>
	    <td></td>
	    </tr>
	    <% } %>
        <tr>
        <td align="right"><input type="submit" id="submit" value="Save"/></td>
        <td>
        <span id="spinner" style="display:none"><img src="../../Resources/ajax-loader.gif" /></span>
        <span id="spinnermsg" style="display:none"></span>
        <div id="participant"></div>
        <span id="validationsummary" style="display:none"><%= Html.ValidationSummary(true)%></span> 
        </td>
        </tr>
	    </table>
	    <div id="rightColumn">
	    <div class="right" id="BulkTool" style="display:none">
           <ul class="rightColumnList" id="Ul1">
               <li class="rightColumnListHeading"><h2>Bulk Insertion Tool</h2></li>
               <li class="rightColumnListItem">Enter email addresses (separated by a comma), or upload them from a file.</li>
               <li class="rightColumnListItem"><%= Html.TextArea("ta_bulk", new { style = "width:200px", rows = "8" })%></li>
               <li class="rightColumnListItem"><input type="button" id="al_bulk_delim" value="Add"/><input type="file" id="up_bulk" name="up_bulk" /></li>
           </ul>
           </div>
            <%  if (Model.SelectedRole == "Poll Administrator" && !Model.IsNew)
                { 
                    Html.RenderPartial("PollAdministratorGroups", Model); 
                }
            %>
        </div>
    


